package com.manlu.controller;

import com.manlu.service.ImageService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Auther 漫路h
 * Created by 2020-05-03 17:49
 */
@RestController
@RequestMapping("/image")
@CrossOrigin
public class ImageController {
    @Resource
    private ImageService imageService;
    @Resource
    private HttpServletRequest request;


    /**
     * 添加图片
     * @param file
     * @return
     */
    @PostMapping("/addImage")
    public String addImage(MultipartFile file){
        //token鉴权用户是否登录
        //已登录,拿到用户信息
            //测试,暂时表示已登录
        String url = imageService.addImage(file,request);
        //未登录,提示用户信息
        return url;
    }
}
